package gsoc.ogsadai.model.diagram.part;

import gsoc.ogsadai.model.diagram.providers.RequestElementTypes;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.gef.Tool;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteDrawer;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeConnectionTool;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeCreationTool;

/**
 * @generated
 */
public class RequestPaletteFactory {

	/**
	 * @generated
	 */
	public void fillPalette(PaletteRoot paletteRoot) {
		paletteRoot.add(createWorkflow1Group());
		paletteRoot.add(createActivity2Group());
	}

	/**
	 * Creates "Workflow" palette tool group
	 * @generated
	 */
	private PaletteContainer createWorkflow1Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.Workflow1Group_title);
		paletteContainer.setDescription(Messages.Workflow1Group_desc);
		paletteContainer.add(createPipeline1CreationTool());
		paletteContainer.add(createParallel2CreationTool());
		paletteContainer.add(createSequential3CreationTool());
		paletteContainer.add(createWorkflow4CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "Activity" palette tool group
	 * @generated
	 */
	private PaletteContainer createActivity2Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.Activity2Group_title);
		paletteContainer.setDescription(Messages.Activity2Group_desc);
		paletteContainer.add(createActivity1CreationTool());
		paletteContainer.add(createInputStream2CreationTool());
		paletteContainer.add(createInputLiteral3CreationTool());
		paletteContainer.add(createOutputStream4CreationTool());
		paletteContainer.add(createConnection5CreationTool());
		return paletteContainer;
	}

	/**
	 * @generated
	 */
	private ToolEntry createPipeline1CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(2);
		types.add(RequestElementTypes.PipelineType_1001);
		types.add(RequestElementTypes.PipelineType_2009);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Pipeline1CreationTool_title,
				Messages.Pipeline1CreationTool_desc, types);
		entry.setSmallIcon(RequestElementTypes
				.getImageDescriptor(RequestElementTypes.PipelineType_1001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createParallel2CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(2);
		types.add(RequestElementTypes.ParallelType_1002);
		types.add(RequestElementTypes.ParallelType_2010);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Parallel2CreationTool_title,
				Messages.Parallel2CreationTool_desc, types);
		entry.setSmallIcon(RequestElementTypes
				.getImageDescriptor(RequestElementTypes.ParallelType_1002));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createSequential3CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(2);
		types.add(RequestElementTypes.SequenceType_2011);
		types.add(RequestElementTypes.SequenceType_1003);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Sequential3CreationTool_title,
				Messages.Sequential3CreationTool_desc, types);
		entry.setSmallIcon(RequestElementTypes
				.getImageDescriptor(RequestElementTypes.SequenceType_2011));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createWorkflow4CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(RequestElementTypes.WorkflowType_2012);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Workflow4CreationTool_title,
				Messages.Workflow4CreationTool_desc, types);
		entry.setSmallIcon(RequestElementTypes
				.getImageDescriptor(RequestElementTypes.WorkflowType_2012));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createActivity1CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(RequestElementTypes.ActivityType_2001);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Activity1CreationTool_title,
				Messages.Activity1CreationTool_desc, types);
		entry.setSmallIcon(RequestElementTypes
				.getImageDescriptor(RequestElementTypes.ActivityType_2001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createInputStream2CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(RequestElementTypes.InputStreamType_2004);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.InputStream2CreationTool_title,
				Messages.InputStream2CreationTool_desc, types);
		entry.setSmallIcon(RequestElementTypes
				.getImageDescriptor(RequestElementTypes.InputStreamType_2004));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createInputLiteral3CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(RequestElementTypes.DataType_2005);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.InputLiteral3CreationTool_title,
				Messages.InputLiteral3CreationTool_desc, types);
		entry.setSmallIcon(RequestElementTypes
				.getImageDescriptor(RequestElementTypes.DataType_2005));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createOutputStream4CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(RequestElementTypes.OutputStreamType_2007);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.OutputStream4CreationTool_title,
				Messages.OutputStream4CreationTool_desc, types);
		entry.setSmallIcon(RequestElementTypes
				.getImageDescriptor(RequestElementTypes.OutputStreamType_2007));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createConnection5CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(RequestElementTypes.OutputStreamTypePipe_3001);
		LinkToolEntry entry = new LinkToolEntry(
				Messages.Connection5CreationTool_title,
				Messages.Connection5CreationTool_desc, types);
		entry
				.setSmallIcon(RequestElementTypes
						.getImageDescriptor(RequestElementTypes.OutputStreamTypePipe_3001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private static class NodeToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List elementTypes;

		/**
		 * @generated
		 */
		private NodeToolEntry(String title, String description,
				List elementTypes) {
			super(title, description, null, null);
			this.elementTypes = elementTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}

	/**
	 * @generated
	 */
	private static class LinkToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List relationshipTypes;

		/**
		 * @generated
		 */
		private LinkToolEntry(String title, String description,
				List relationshipTypes) {
			super(title, description, null, null);
			this.relationshipTypes = relationshipTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}
}
